<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

    <style>
        div {
            height: 100px;
            width: 100px;
        }

    </style>

</head>

<body>

<button onclick="sendMessage()">发送一个消息给原生</button>
<img src="" alt="" style="display: none;" id="img">
<div onclick="takePhoto()">拍照</div>
<div onclick="show()">消息</div>

<script>

    function show() {
        if(window.glo) {
            window.glo.showToast('aaaaaaaaaaa')
        }
    }

    function sendMessage() {
        if (currentPort) {
            currentPort.postMessage(JSON.stringify({ type: 'alert', message: '我是h5的消息' }))
        } else {
            alert("消息不通")
        }
    }


    function takePhoto() {
        if(window.glo) {
            window.glo.takePhoto()
        }
    }

    function getPhotoUrl(url) {
        document.querySelector('#img').style.display = 'block'
        document.querySelector('#img').src = url
    }


</script>

</body>

</html>